package cate.game.role.pvp.championrace.msg;

import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBChampionRace;
import cate.game.pvp.championrace.data.ChampionRaceSpec;
import cate.game.pvp.championrace.ChampionRaceSpecUtils;

import java.util.Objects;

public class ChampionRaceRoundReq implements MsgInput {
    public ChampionRaceSpec from;
    public ChampionRaceSpec to;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        ChampionRaceSpecUtils.SpecPair pair = ChampionRaceSpecUtils.checkQuerySpec(from, to,
                game.pvp.championRace.getSpec());
        if (Objects.isNull(pair)) {
            game.notice.message(cc.getRole(), "参数错误!");
            return;
        }
        this.from = pair.getFrom();
        this.to = pair.getTo();
        ChampionRaceRoundResp r = game.pvp.championRace.getBizHandler().getRounds(cc.getRole().getUid(), this);
        if (r != null) {
            cc.sendNow(r);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBChampionRace.ROUND_REQ;
    }
}
